import java.sql.*;

public class JDBCExample1 {
	public static void main(String[] argv) {
		
		 
		System.out.println("-------- PostgreSQL "
				+ "JDBC Connection Testing ------------");
 
		try { // Initialisierung Treiber
 
			Class.forName("org.postgresql.Driver");
			
 
		} catch (ClassNotFoundException e) {
 
			System.out.println("Where is your PostgreSQL JDBC Driver? "
					+ "Include in your library path!");
			e.printStackTrace();
			return;
 
		}
 
		System.out.println("PostgreSQL JDBC Driver Registered!");
 
		Connection connection = null;
 
		try { // Verbindungsaufbau zu Datenbank
 
			connection = DriverManager.getConnection(
					"jdbc:postgresql://localhost:5432/CATDAT", "postgres",
					"dast");
			
			Statement statement = connection.createStatement();
			ResultSet result = statement.executeQuery("SELECT * FROM iket.event_earthquake");		
						
			while (result.next()) //interner Cursor wird auf die erste Zeile gesetzt
			{   
				String depth_0_bis_15km = result.getString("depth_0_bis_15km");
				Statement statement2 = connection.createStatement();				
				System.out.println( result.getString(23) );
				String updateString = "UPDATE iket.event_earthquake SET depth=" + "'16,0' WHERE depth LIKE '16'";
				statement2.executeUpdate(updateString);
				
					
			}
			
			result.close();	
			statement.close();
			connection.close();
						
		} catch (SQLException e) {
 
			System.out.println("Connection Failed! Check output console");
			e.printStackTrace();
			return;
			
 
		}
 
		if (connection != null) {
			System.out.println("You made it, take control your database now!");
			
			
		} else {
			System.out.println("Failed to make connection!");
		}
	}
 

}
